
function getComments(page,mId){
	$.ajax( {
		url : "getComments!get.action",
		type : "POST",
		data : {
			pageNow : page,
			musicId : mId
		},
		dataType : "json",
		success : function(data){
			setComments(data);
		}
	});
}

function addComment(mId){
	comment = $('#message_short').val();
	$.ajax( {
		url : "getComments!add.action",
		type : "POST",
		data : {
			content : comment,
			musicId : mId
		},
		dataType : "json",
		success : function(data){
			if(data.flag == "没有登录"){
				$('#login_popup').show();
			}else{
				getComments(1,mId);	
			}
		}
	});
}
function setComments(data){
	$('#wall_list > ul').html('');
	if(data.page.totalSize >= 0){
		$('#comments_num').html(data.page.totalSize+'<span>评论</span>');
		$('p[class="wall_list_count"]').html('<span>'+data.page.totalSize+'</span>条简评');
		$.each(data.comments, function(index, value) {
		$('#wall_list > ul').append('<li id="'+value.sourceId+'"><div class="post_item"><p class="usr_cover"><a class="personalDropDown" href="'+value.sourceId+'" title="Kirishima.UK"> <img src="'+value.sourceImage+'" width="50" height="50" alt="Kirishima.UK"> </a></p><div class="info"> <span class="author"><a href="'+
			value.sourceId+'" title="Kirishima.UK">'+value.sourceName+'</a></span><span class="time">'+value.time+'</span></div><div class="brief"><div id="brief_11061724">'+value.content+'</div></div></div></li>');
		});
		$('div[class="all_page"]').html('');
		if(data.page.totalPage >=1){
			for(i=1;i<=data.page.totalPage;i++){
			if(i == data.page.pageNow){
				$('div[class="all_page"]').append('<a class="p_num p_curpage">'+i+'</a>');
			}else{
				$('div[class="all_page"]').append('<a href="javascript:getComments('+i+');" class="p_num">'+i+'</a>');
			}
		}
		if(data.page.hasNext == 1){
			$('div[class="all_page"]').append('<a href="javascript:getComments('+(data.page.pageNow+1)+');" class="p_num">下一页</a>');
		}
		$('div[class="all_page"]').append('<span>(第'+data.page.pageNow+'页)</span>');
		}
	}
}

function login(){
	$.ajax( {
		url : "loginAjax",
		type : "POST",
		data : {
			username : $('#username')[0].value,
			password : $('#password')[0].value
		},
		dataType : "json",
		success : function(data){
			if(data.flag == 1){
				$('#login_popup').hide();
			}else{
				$('#login_tips').html('用户名或密码错误');
			}
		}
	});
}